<?php

namespace Drupal\gdlisnet\Entity;

use Drupal\Core\Entity\EntityType;
use Drupal\gdlisnet\CollectionInterface;
use Drupal\Core\Entity\EntityTypeInterface;

/**
 * Defines the collection entity.
 *
 * @EntityType(
 *   id = "collection",
 *   label = @Translation("Collection"),
 *   entity_keys = {
 *     "id" = "主键码",
 *   },
 *   handlers = {
 *     "storage" = "Drupal\gdlisnet\Entity\CollectionStorage"
 *   },
 *   links = {
 *     "canonical" = "/gdlisnet/collection/{collection}",
 *   },
 *  )
 */
class Collection extends EntityType implements CollectionInterface {
	public function __construct(array $record, $entity_type) {
		if($record==FALSE) return NULL;
		$this->id=$record['主键码'];
		$record['id']=$record['主键码'];
		return parent::__construct($record, $entity_type);
	}
	
	public static function postLoad() {
	}

	public function __toString() {
		return $this->get('marc')->__toString();
	}
}
